<template>
	<div class="my-course">
		<el-table
		:data="tableData"
		border
		style="width: 100%">
		<el-table-column
		type="index"
		label="序号"
		width="80">
		</el-table-column>
		<el-table-column
		prop="projectName"
		label="课程名称">
		</el-table-column>
		<el-table-column
		label="操作"
		width="100">
			<template slot-scope="scope">
				<el-button type="text" size="small" @click="handleLearn(scope.row)">去学习</el-button>
			</template>
		</el-table-column>
	</el-table>
	</div>
</template>

<script>
import { listCoursePay } from '@/api/web/index'
import user from '@/store/modules/user'
export default {
	name: 'MyCourse',
	data() { 
		return {
			//表格数据
			tableData: []
		}
	},
	mounted() { 
		this.queryCourseBuy();
	},
	methods: {
		/**
		 * 查询已购买课程列表
		 */
		async queryCourseBuy() {
			let res = await listCoursePay({
				userId: user.state.id
			});
			if (res.code == 200) { 
				this.tableData = res.rows;
			}
		},
		/**
		 * 去学习
		 * @param row 
		 */
		handleLearn(row) { 
			this.$router.push({
				path: '/videoView',
				query: {
					courseId: row.courseId,
					mediaId: ''
				}
			})
		}
	}
}
</script>

<style lang="scss" scoped>
</style>